import java.util.Arrays;
import java.util.Scanner;
class PersonOverride {
	private String name;      
    private boolean gender;
    private  int age;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public boolean isGender() {
		return gender;
	}
	public void setGender(boolean gender) {
		this.gender = gender;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
    public PersonOverride(String name,int age,boolean gender){
        this.name=name;
        this.age =age;
        this.gender=gender;
    }
    public PersonOverride(){
    	this("default",1,true);
    }
	public String toString() {
		return (name+"-"+age+"-"+gender);
	}
	public boolean equals(Object other){
		if (this==other) {
			return true;
		}
		if (other == null){
			return false;
		}
		if (getClass() != other.getClass())
			return false;
		PersonOverride obj=(PersonOverride) other;
		if (age != obj.age)
			return false;
		if(gender!=obj.gender)
			return false;
		if (name == null) {
			if (obj.name != null)
				return false;
		} else if (!name.equals(obj.name))
			return false;
		return true;
	}
}

public class Main {
	private static int flag;
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n1=in.nextInt();
		int n2=in.nextInt();
		int count=0;
		PersonOverride[] person1=new PersonOverride[n1];
		PersonOverride[] person2=new PersonOverride[n2];
		for (int i = 0; i < n1; i++) {
			person1[i]=new PersonOverride();
		}
		for (int i = 0; i < n2; i++) {
			PersonOverride other=new PersonOverride(in.next(),in.nextInt(),in.nextBoolean());
			if(i==0){
				person2[i]=other;
				continue;
			}
			for (int j = 0; j <i; j++) {
				if(person2[j]!=null)
					if(other.equals(person2[j]))  flag=1;
			}
			if(flag==0){
				person2[i]=other;
			}
			flag=0;
		}
		for (int j1 = 0; j1 < person1.length; j1++) {
			System.out.println(person1[j1]);
		}
		for (int j2 = 0; j2 < person2.length; j2++) {
			if(person2[j2]!=null){
				System.out.println(person2[j2]);
				count++;
			}
		}
		System.out.println(count);
		System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));
        in.close();
	}
}